function s(select){
    return document.querySelector(select);
}
function reEnter() {
    s('.info').style.display = 'block';
    setTimeout(function(){
        window.location.href = 'enter.html';
    },1500);
}
window.onload = function(){
    var name = document.getElementById("name");
    var foot = document.querySelector("footer");
    var waitPayNum = document.querySelector("#waitPayNum");
    var waitReceiveNum = document.querySelector("#waitReveiceNum");
    var num = document.querySelector("#cartNum");
    var token = selectByKey("like_token");
    //ajax请求个人信息
    $.ajax({
        url:pathName+"/api/v1/member",
        type:"get",
        dataType:"json",
        headers:{
            "Accept":"application/json",
            "Authorization":"Bearer "+token
        },
        success:function(data){
            console.log(data);
            var mask = document.querySelector(".mask");
            mask.style.display = "none";
            name.innerHTML = data.member.phone;
            waitReceiveNum.innerHTML = data.orderNum.waitGoodNum;
            waitPayNum.innerHTML = data.orderNum.waitPayNum;
        },
        error:function(){
            if(!token){
                reEnter();
            }
        }
    })
    Tap(foot,function(){
        window.location.href = '../service.html';
    })
    //ajax请求购物车数量
    $.ajax({
        url:pathName+"/api/v1/member/cartNum",
        type:"GET",
        headers:{
            "accept":"application/json",
            "Authorization":"Bearer "+ token
        },
        success:function(data){
            num.innerHTML = data.cartNum;
        },
        error:function(){
            if(!token){
                reEnter();
            }
        }
    })
    //ajax请求优惠券数量
    $.ajax({
        url:pathName+"/api/v1/member/myCoupons",
        type:"get",
        headers:{
            "Accept":"application/json",
            "Authorization":"Bearer "+token
        },
        success:function(res){
            console.log(res);
            var num = 0;
            for(var k in res.data){
                num++;
            }
            var youhui = document.getElementById("youhui");
            youhui.innerHTML = num;
        }
    })
    $.ajax({
        url:pathName+"/api/v1/member/usertype",
        type:"get",
        headers:{
            "Accept":"application/json",
            "Authorization":"Bearer "+token
        },
        success:function(res){
            if(res.userType==2){
            	$(".addCenter").after('<a href="../../views/cityWideCenter/operationCenter.html" title="运营中心"><p><img class="simgo" style="top: 9px;" src="../../statics/images/individual/iconfont-chanpin.png" alt="运营中心"/>运营中心<img class="simgt" src="../../statics/images/individual/arrow.png" alt="返回"/></p></a>')
            }else if(res.userType==0){
            	console.log("个人用户")
            }else{
            	console.log("其他用户")
            }
        }
    })
}